package com.cvtt.xmpp.utils;

public class XMPPErrorType {
	protected static String[] reasons;

	private static boolean is_init = false;

	protected static void init()
	{
		
		String[] reasons = new String[700];
		for (int i = 0; i < 700; i++)
			reasons[i] = null;

		// Not defined (included just to robustness)
		reasons[0] = "未知错误";

		reasons[302] = "gone";  //MODIFY 
		reasons[302] = "redirect";  //MODIFY 
		reasons[400] = "bad-request";  //MODIFY > 
		reasons[400] = "jid-malformed";  //MODIFY 
		reasons[400] = "unexpected-condition";  //WAIT 
		reasons[404] = "item-not-found";  //CANCEL 
		reasons[404] = "recipient-unavailable";  //WAIT 
		reasons[404] = "remote-server-not-found";  //CANCEL 
		reasons[405] = "not-allowed";  //CANCEL 
		reasons[406] = "no-acceptable";  //MODIFY 
		reasons[408] = "request-timeout";  //CANCEL 
		reasons[409] = "conflict";  //CANCEL 
		reasons[500] = "interna-server-error";  //WAIT 
		reasons[500] = "undefined-condition";  //WAIT 
		reasons[500] = "resource-constraint";  //WAIT 
		reasons[501] = "feature-not-implemented";  //CANCEL 
		reasons[502] = "remote-server-error";  //CANCEL 
		reasons[503] = "service-unavailable";  //CANCEL 
		reasons[504] = "remote-server-timeout";  //WAIT 
		
	}
	/**
	 * 根据错误码获取错误信息
	 * */
	public static String reasonOf(int code) {
		if (!is_init)
			init();
		if (reasons[code] != null)
			return reasons[code];
		else
			return reasons[((int) (code / 100)) * 100];
	}
}
